<%@page import="com.eportal.util.WebUtil"%>
<%@ page language="java" pageEncoding="utf-8"%>
<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge, chrome=1">
    <meta name="renderer" content="webkit">
    <META HTTP-EQUIV="Pragma" CONTENT="no-cache">
    <META HTTP-EQUIV="Cache-Control" CONTENT="no-cache">
    <META HTTP-EQUIV="Expires" CONTENT="0">
    <title>添加商品</title>

    <link href="${pageContext.request.contextPath}/static/css/common.css" rel="stylesheet">
    <link href="${pageContext.request.contextPath}/static/plugins/bootstrap-3.3.5/css/bootstrap.min.css" rel="stylesheet">
    <%--<link href="${pageContext.request.contextPath}/static/plugins/font-awesome-4.3.0/css/font-awesome.min.css" rel="stylesheet">--%>
    <%--<!-- jqgrid-->--%>
    <%--<link href="${pageContext.request.contextPath}/static/plugins/jqGrid/css/custom.ui.jqgrid.css" rel="stylesheet">--%>
    <%--<link href="${pageContext.request.contextPath}/static/plugins/layer/skin/layer.css" rel="stylesheet">--%>
    <%--<link href="${pageContext.request.contextPath}/static/plugins/jqGrid/css/style.css" rel="stylesheet">--%>
	<%--<link href="${pageContext.request.contextPath}/static/plugins/select2-4.0.0/dist/css/select2.min.css" rel="stylesheet">--%>
    <script src="${pageContext.request.contextPath}/static/js/jquery-1.11.3.min.js"></script>
    <script src="${pageContext.request.contextPath}/static/js/jquery.form.js"></script>
    <%--<script src="${pageContext.request.contextPath}/static/js/common.js"></script>--%>
    <%--<script src="${pageContext.request.contextPath}/static/plugins/bootstrap-3.3.5/js/bootstrap.min.js"></script>--%>
    <%--<script src="${pageContext.request.contextPath}/static/plugins/jqGrid/js/i18n/grid.locale-cn.js"></script>--%>
    <%--<script src="${pageContext.request.contextPath}/static/plugins/jqGrid/js/minified/jquery.jqGrid.min.js"></script>--%>
    <%--<script src="${pageContext.request.contextPath}/static/plugins/layer/layer.js" type="text/javascript"></script>--%>
    <%--<script src="${pageContext.request.contextPath}/static/js/global.js"></script>--%>
	<%--<script src="${pageContext.request.contextPath}/static/plugins/select2-4.0.0/dist/js/select2.min.js"></script>--%>
	<%--<script type="text/javascript" src="${pageContext.request.contextPath}/static/plugins/My97DatePicker/WdatePicker.js"></script>--%>

</head>
<body >

<div>
	<form action="${pageContext.request.contextPath}/admin/mall_commodityAdd.action" enctype="multipart/form-data" method="post">
		<table border="1">
			<tr>
				<td>商品名称:</td>
				<td><input type="text" name="cname" value="测试商品"/></td>
			</tr>
			<tr>
				<td>商品库存:</td>
				<td><input type="text" name="stock" value="200"/></td>
			</tr>
			<tr>
				<td>商品图片:</td>
				<td>
					<input type="file" name="attrPhoto1"/>
					<input type="file" name="attrPhoto2"/>
					<input type="file" name="attrPhoto3"/>
					<input type="file" name="attrPhoto4"/>
				</td>
			</tr>
			<tr>
				<td>商品价格:</td>
				<td>
					<table border="1">
						<tr>
							<td colspan="2">数量区间</td>
							<td>价格</td>
						</tr>
						<tr>
							<td><input type="text" name="startNum" value="1"/></td>
							<td><input type="text" name="endNum" value="2"/></td>
							<td><input type="text" name="price" value="80"/></td>
						</tr>
						<tr>
							<td><input type="text" name="startNum" value="3"/></td>
							<td><input type="text" name="endNum" value="4"/></td>
							<td><input type="text" name="price" value="70"/></td>
						</tr>
						<tr>
							<td><input type="text" name="startNum" value="5"/></td>
							<td><input type="text" name="endNum" value="6"/></td>
							<td><input type="text" name="price" value="60"/></td>
						</tr>
					</table>
				</td>
			</tr>
			<tr>
				<td>图片描述:</td>
				<td><input type="file" name="photoM"/></td>
			</tr>
			<tr>
				<td>参数描述:</td>
				<td>
					<input type="text" name="propertyName" value="支持电压"/>--
					<input type="text" name="propertyVal" value="支持的电压为250V-300V"/>
					<input type="text" name="propertyName" value="支持电压"/>--
					<input type="text" name="propertyVal" value="支持的电压为250V-300V"/>
				</td>
			</tr>
			<tr>
				<td colspan="2">
					<input align="center" type="button" onclick="commodityAdd()" value="提交" name="提交"/>
				</td>
			</tr>
		</table>
	</form>
</div>
 <script type="text/javascript">
	 //添加
	 function commodityAdd(){
		 console.log('提交');
		 var formData = new FormData($( "form" )[0]);
		 var url = '${pageContext.request.contextPath}/admin/mall_commodityAdd.action';
//		 $.post(url,{data:formData}, function (result) {
//			console.log(JSON.stringify(result));
//		 })

		 //var formData = new FormData($( "#uploadForm" )[0]);
		 $.ajax({
			 url: url ,
			 type: 'POST',
			 data: formData,
			 async: false,
			 cache: false,
			 contentType: false,
			 processData: false,
			 success: function (result) {
				 result = JSON.parse(result)
				 if (result.code == 1) {
					 alert("保存成功");
				 }else{
					 alert(result.msg);
				 }
			 },
			 error: function (returndata) {
				 alert(returndata);
			 }
		 });
	 }

 </script>
</body>
</html>
